package com.pro.controller;

import com.pro.pojo.JsApplyRecord;
import com.pro.pojo.JsAuditLog;
import com.pro.pojo.JsonData;
import com.pro.pojo.SyCourseRecord;
import com.pro.service.JsApplyRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/JsApplyRecord")
public class JsApplyRecordController {

    @Autowired
    private JsApplyRecordService jar;

    //申请列表
    @RequestMapping("/getJsApplyRecordList")
    @ResponseBody
    public JsonData getJsApplyRecordList(JsApplyRecord jsApplyRecord){
        List<JsApplyRecord> jsApplyRecordList = jar.getJsApplyRecordList(jsApplyRecord);
        return jsApplyRecordList!=null?JsonData.buildSuccess(jsApplyRecordList):JsonData.buildError("服务器出错了");
    }

    //不同状态获取不同的用户
    @RequestMapping("/getJsApplyRecordListStatus")
    @ResponseBody
    public JsonData getJsApplyRecordListStatus(JsApplyRecord jsApplyRecord){
        List<JsApplyRecord> jsApplyRecordList = jar.getJsApplyRecordListStatus(jsApplyRecord);
        return jsApplyRecordList!=null?JsonData.buildSuccess(jsApplyRecordList):JsonData.buildError("服务器出错了");
    }

    //添加用户申请审核记录
    @RequestMapping("/addCourseRecord")
    @ResponseBody
    public JsonData addCourseRecord(SyCourseRecord syCourseRecord){
        boolean b = jar.addCourseRecord(syCourseRecord);
        return b?JsonData.buildSuccess(b):JsonData.buildError("服务器出错了");
    }

    //审核后修改用户的申请状态
    @RequestMapping("/updateJsApplyRecordResult")
    @ResponseBody
    public JsonData updateJsApplyRecordResult(JsApplyRecord jsApplyRecord){
        boolean b = jar.updateJsApplyRecordResult(jsApplyRecord);
        return b?JsonData.buildSuccess(b):JsonData.buildError("服务器出错了");
    }

    //审核后添加审核日志
    @RequestMapping("/addJsAuditLog")
    @ResponseBody
    public JsonData addJsAuditLog(JsAuditLog jsAuditLog){
        boolean b = jar.addJsAuditLog(jsAuditLog);
        return b?JsonData.buildSuccess(b):JsonData.buildError("服务器出错了");
    }
}
